const process = require('child_process');
const JiraService = require('../Services/JiraService');
const JiraProcess = require('../Services/JiraProcess');



module.exports = () => {
    /**
     * 开启一个子进程用于定时从Jira服务器中获取数据，并保存到数据库；
     * 在子进程出现异常断开或退出时，自动重启进程。
     */
    let jira_process = process.fork(JiraProcess, { silent: true });

    jira_process.on('diconnect', function () {
        jira_process.kill();
        jira_process = process.fork(JiraProcess, { silent: true });
    });

    jira_process.on('exit', function () {
        jira_process = process.fork(JiraProcess, { silent: true });
    });
}